package com.gm.wholesale.util;
import android.text.TextUtils;
import com.gm.wholesale.constant.Constant;
import com.gm.wholesale.module.order.bean.OrderRecmPriceBean;
import com.gm.wholesale.module.user.UserDataManger;
public class Utils {
    public static boolean isWeightUnit(String unit) {
        if (TextUtils.isEmpty(unit)) {
            return false;
        }
        unit = unit.toLowerCase();
        String units[] = Constant.WEIGHT_UNIT.split(",");
        for (String unit2 : units) {
            if (unit2.equals(unit)) {
                return true;
            }
        }
        return false;
    }

    public static String getToken() {
        try {
            String token = UserDataManger.newInstance().getToken();
            if (!TextUtils.isEmpty(token)) {
                String tokes[] = token.split("\\.");
                return new String(Base64Util.getUrlDecoder().decode(tokes[1]));
            }
        } catch (Exception e) {
            return "";
        }
        return "";
    }


    public  static double getOrderRecmPrice(OrderRecmPriceBean orderRecmPriceBean) {
        if (orderRecmPriceBean == null) {
            return 0;
        }
        if (!TextUtils.isEmpty(orderRecmPriceBean.getLastPrice())) {
            double price=Double.parseDouble(orderRecmPriceBean.getLastPrice());
            if (price>0){
                return price;
            }
        }
        if (!TextUtils.isEmpty(orderRecmPriceBean.getHighFrequencyPrice())) {
            double price=Double.parseDouble(orderRecmPriceBean.getHighFrequencyPrice());
            if (price>0){
                return price;
            }

        }

        if (!TextUtils.isEmpty(orderRecmPriceBean.getTagPrice())) {
            double price=Double.parseDouble(orderRecmPriceBean.getTagPrice());
            if (price>0){
                return price;
            }
        }
        return 0;
    }



}
